//
//  UIViewController+ZYAlertView.m
//  TTYL
//
//  Created by apple on 16/5/3.
//  Copyright © 2016年 乾坤. All rights reserved.
//

#import "UIViewController+ZYAlertView.h"

@implementation UIViewController (ZYAlertView)
- (void)createAlertViewWithTitle:(NSString *)title message:(NSString *)message preferredStyle:(UIAlertControllerStyle)preferredStyple disapperaTime:(CGFloat)times andDis:(disMiss)dis{
    
    UIAlertController *alert  = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:preferredStyple];
    if (times == 0) {
        UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
        }];
        
        [alert addAction:defaultAction];
    }
    [self presentViewController:alert animated:YES completion:^{
        if (times != 0) {
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(times * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                //dis();
                [self dismissViewControllerAnimated:YES completion:nil];
            });
        }
    }];
    
}

@end
